
use UMAS0005_OUTPUT.DTA, clear

sort zipcode
merge zipcode using "zcta_cbsa_rel_10.dta"
drop if _m<3

gen region=1 if cbsa==14460
replace region=2 if cbsa==12700 | cbsa==39300
replace region=3 if cbsa==49340
replace region=4 if cbsa==38340 | cbsa==44140
label define region 1 "Boston Area" 2 "New Bedford/Cape Cod" 3 "Central MA" 4 "Western MA"
label values region region

gen incomecat=1 if faminc<=4
replace incomecat=2 if faminc>4 & faminc<10
replace incomecat=3 if faminc<97 & faminc>10

label define incomecat 1 "Less than $40k" 2 "$40k - $100k" 3 "Over $100k"
label values incomecat incomecat

gen age=2012-birthyr
gen agecat=1 if age<30
replace agecat=2 if age>29 & age<55
replace agecat=3 if age>54

label define agecat 1 "18-29" 2 "30-54" 3 "55+"
label values agecat agecat

svyset [pw=weight]

log using pollresults.log, replace

* State of State/Nation

svy: tab UMAQ1
svy: tab UMAQ2

* Favorability
svy: tab UMAQ3a, stubw(30)
svy: tab UMAQ3b, stubw(30)
svy: tab UMAQ3c, stubw(30)
svy: tab UMAQ3d, stubw(30)
svy: tab UMAQ3e, stubw(30)
svy: tab UMAQ3f, stubw(30)

* Senate race
recode UMAQ9 3=1 4=2
gen senwleaners=UMAQ9
replace senwleaners=1 if UMAQ9a==1
replace senwleaners=2 if UMAQ9a==2
label values senwleaners UMAQ9

* Registered voters (no leaners)

svy: tab UMAQ9, stubw(30)

* Registered voters (including leaners)

svy: tab senwleaners, stubw(30)

* Likely voters (no leaners)

svy: tab UMAQ9 if UMAQ5==1, stubw(30)

* Likely voters (including leaners)

svy: tab senwleaners if UMAQ5==1, stubw(30)


svy: tab senwleaners gender if UMAQ5==1, stubw(30) col
svy: tab senwleaners incomecat if UMAQ5==1, stubw(30) col
svy: tab senwleaners agecat if UMAQ5==1, stubw(30) col
svy: tab senwleaners pid3 if UMAQ5==1, stubw(30) col
svy: tab senwleaners region if UMAQ5==1, stubw(30) col


* Would you change vote?

svy: tab UMAQ9b
svy: tab UMAQ9c

* Issue comparisons

svy: tab UMAQ12a
svy: tab UMAQ12b
svy: tab UMAQ12c
svy: tab UMAQ12d

* Would work with other party?

svy: tab UMAQ14

* Traits

svy: tab UMAQ15a
svy: tab UMAQ15b
svy: tab UMAQ15c
svy: tab UMAQ15d

* More negative campaign?

svy: tab UMAQ17

* Better representative for different groups?

svy: tab UMAQ16a
svy: tab UMAQ16b
svy: tab UMAQ16c
 
* Regional breakdown, likely voters, including leaners
svy: tab senwleaners if UMAQ5==1 & region==1, stubw(30) 
svy: tab senwleaners if UMAQ5==1 & region==2, stubw(30) 
svy: tab senwleaners if UMAQ5==1 & region==3, stubw(30)
svy: tab senwleaners if UMAQ5==1 & region==4, stubw(30) 
 
 log close
